package com.bh.order.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bh.common.annotation.Dict;
import com.bh.common.annotation.Excel;
import com.bh.common.annotation.KyAbnormal;
import com.bh.common.enums.YesOrNo;
import com.bh.common.core.domain.BhtmsBaseEntity;
import com.bh.dispatch.domain.JcDispatch;
import com.bh.extend.domain.JcAbnormal;
import com.bh.extend.domain.JcCustomer;
import com.bh.kysys.domain.JcSysOrganization;
import com.bh.ledger.domain.JcLedgerDetail;
import com.bh.ledger.domain.JcVerificationZb;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.poi.ss.usermodel.HorizontalAlignment;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 订单管理对象 jc_order
 *
 * @author slx
 * @date 2023-08-12
 */
@EqualsAndHashCode(callSuper = true)
@TableName("jc_order")
@Data
public class JcOrder extends BhtmsBaseEntity implements Serializable {
    

    /**
     * 回单份数
     */
    @KyAbnormal(name = "回单份数")
    @ApiModelProperty("回单份数")
    @Excel(name = "回单份数")
    private Integer backNumber;

    /**
     * 是否超期
     */
    @ApiModelProperty("是否超期")
    @Excel(name = "是否超期")
    private Integer customerIsExceed;

    /**
     * 客户名称
     */
    @KyAbnormal(name = "零散客户名称")
    @ApiModelProperty("客户名称")
    @Excel(name = "客户名称", align = HorizontalAlignment.LEFT)
    private String customerName;

    /**
     * 客户类型
     * 1	合同
     * 0	零散
     */
    @KyAbnormal(name = "客户类型", dataBookName = "CustomerType")
    @ApiModelProperty("客户类型")
    @Excel(name = "客户类型")
    private Integer customerType;

    /**
     * 结算方式
     */
    @KyAbnormal(name = "结算方式", dataBookName = "Clearing")
    @ApiModelProperty("结算方式")
    @Excel(name = "结算方式")
    private Integer feeType;

    // 实际发运时间
    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date fyTime;

    /**
     * 交付方式
     */
    @KyAbnormal(name = "交付方式", dataBookName = "HandoverType")
    @ApiModelProperty("交付方式")
    @Excel(name = "交付方式")
    private Integer handoverType;

    /**
     * 异常
     */
    @KyAbnormal(name = "是否有异常", dataBookName = "CommIsNot")
    @ApiModelProperty("异常")
    @Excel(name = "异常")
    private Integer isAbnormal;

    /**
     * 是否回单
     */
    @KyAbnormal(name = "交付方式", dataBookName = "CommIsNot")
    @ApiModelProperty("是否回单")
    @Excel(name = "是否回单")
    private Integer isBack;


    private Integer isBilling;

    /**
     * 件数
     */
    @ApiModelProperty("件数")
    @Excel(name = "件数")
    private Integer number = 0;

    /**
     * 订单公里数
     */
    @KyAbnormal(name = "订单公里数")
    @ApiModelProperty("订单公里数")
    @Excel(name = "订单公里数")
    private Double orderMileage;

    /**
     * 发货单号
     */
    @KyAbnormal(name = "发货单号")
    @ApiModelProperty("发货单号")
    @Excel(name = "发货单号")
    private String relateBill1;

    /**
     * 客户单号
     */
    @ApiModelProperty("客户单号")
    @Excel(name = "客户单号")
    private String relateBill2;

    /**
     * 客户订单号3
     */
    @ApiModelProperty("客户订单号3")
    @Excel(name = "客户订单号3")
    private String relateBill3;

    /**
     * 客户订单号4
     */
    @ApiModelProperty("客户订单号4")
    @Excel(name = "客户订单号4")
    private String relateBill4;

    /**
     * 客户订单号5
     */
    @ApiModelProperty("客户订单号5")
    @Excel(name = "客户订单号5")
    private String relateBill5;

    /**
     * 销售负责人
     */
    @KyAbnormal(name = "销售负责人")
    @ApiModelProperty("销售负责人")
    @Excel(name = "销售负责人")
    private String salePerson;

    /**
     * 运输方式
     */
    @ApiModelProperty("运输方式")
    @Excel(name = "运输方式")
    private Integer shipmentMethod;

    /**
     * 收入成本确认状态
     */
    @ApiModelProperty("收入成本确认状态")
    @Excel(name = "收入成本确认状态")
    private Integer isConfirm;

    /**
     * 开单日期
     */
    @KyAbnormal(name = "开单日期")
    @ApiModelProperty("开单日期")
    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd")
    @Excel(name = "开单日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date time;

    /**
     * 运输性质
     */
    @KyAbnormal(name = "交付方式", dataBookName = "TransportPro")
    @ApiModelProperty("运输性质")
    @Excel(name = "运输性质")
    private Integer transportPro;


    private BigDecimal value = BigDecimal.ZERO;

    /**
     * 体积
     */
    @ApiModelProperty("体积")
    @Excel(name = "体积")
    private BigDecimal volume = BigDecimal.ZERO;

    /**
     * 重量
     */
    @ApiModelProperty("重量")
    @Excel(name = "重量")
    private BigDecimal weight = BigDecimal.ZERO;

    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date ydTime;

    /**
     * 客户
     */
    @KyAbnormal(name = "客户", clszz = JcCustomer.class)
    @ApiModelProperty("客户")
    @Excel(name = "客户")
    private Long jcCustomerId;

    /**
     * 组织机构(出发网点)
     */
    @ApiModelProperty("组织机构(出发网点)")
    @Excel(name = "组织机构(出发网点)")
    private Long jcOrganizationId;

    /**
     * 派车单
     */
    @ApiModelProperty("派车单")
    @Excel(name = "派车单")
    private Long jcDispatchId;

    /**
     * 实际运抵日期
     */
    @ApiModelProperty("实际运抵日期")
    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "实际运抵日期", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date factArriveTime;

    /**
     * 实际发运时间
     */
    @ApiModelProperty("实际发运时间")
    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "实际发运时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date factLeaveTime;

    /**
     * 要求到达时间
     */
    @KyAbnormal(name = "要求到达时间")
    @ApiModelProperty("要求到达时间")
    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd")
    @Excel(name = "要求到达时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date planArriveTime;

    /**
     * 要求发运时间
     */
    @KyAbnormal(name = "要求发运时间")
    @ApiModelProperty("要求发运时间")
    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd")
    @Excel(name = "要求发运时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date planLeaveTime;

    /**
     * 起运站
     */
    @ApiModelProperty("起运站")
    @Excel(name = "起运站")
    private Long jcFromOrganizationId;

    /**
     * 目的站
     */
    @KyAbnormal(name = "目的站", clszz = JcSysOrganization.class)
    @ApiModelProperty("目的站")
    @Excel(name = "目的站")
    private Long jcToOrganizationId;


    @Dict(dictTable = "jc_sys_organization", dictLabel = "name", dictValue = "id")
    @ApiModelProperty("站点路由")
    @Excel(name = "站点路由")
    private String routerOrgIds;



    private BigDecimal hxMoney;

    /**
     * 核销类型
     */
    @ApiModelProperty("核销类型")
    @Excel(name = "核销类型")
    private Integer hxType;

    /**
     * 未核销金额
     */
    @ApiModelProperty("未核销金额")
    @Excel(name = "未核销金额")
    private BigDecimal whxMoney;

    /**
     * 入库区域
     */
    @KyAbnormal(name = "库存区域", clszz = JcZoneStoreroom.class)
    @ApiModelProperty("入库区域")
    @Excel(name = "入库区域")
    private Long jcZoneStoreroomId;

    /**
     * 目的运点
     */
    @KyAbnormal(name = "目的运点", clszz = JcServerZone.class)
    @ApiModelProperty("目的运点")
    @Dict(dictTable = "jc_server_zone", dictLabel = "name", dictValue = "id", dictAlias = "jcEndZoneIdName")
    @Excel(name = "目的运点")
    private Long jcEndZoneId;
    @TableField(exist = false)
    private String jcEndZoneIdName;

    /**
     * 出发运点
     */
    @KyAbnormal(name = "出发运点", clszz = JcServerZone.class)
    @Dict(dictTable = "jc_server_zone", dictLabel = "name", dictValue = "id", dictAlias = "jcStartZoneIdName")
    @Excel(name = "出发运点")
    private Long jcStartZoneId;
    @TableField(exist = false)
    private String jcStartZoneIdName;

    /**
     * 是否拆单
     */
    @ApiModelProperty("是否拆单")
    @Excel(name = "是否拆单")
    private Integer isTake = 0;

    /**
     * 代收货款
     */
    @ApiModelProperty("代收货款")
    @Excel(name = "代收货款")
    private BigDecimal agent;

    /**
     * 签收时间
     */
    @ApiModelProperty("签收时间")
    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "签收时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date qsTime;

    /**
     * 签收人
     */
    @Dict(dictTable = "sys_user", dictLabel = "nick_name", dictValue = "user_id")
    @ApiModelProperty("签收人")
    @Excel(name = "签收人")
    private String qsPerson;

    /**
     * 计重
     */
    @ApiModelProperty("计重")
    @Excel(name = "计重")
    private BigDecimal jzWeight;

    /**
     * 预录单ID
     */
    @ApiModelProperty("预录单ID")
    @Excel(name = "预录单ID")
    private Long jcPrescoId;

    /**
     * 计算方式
     */
    @ApiModelProperty("计算方式")
    @Excel(name = "计算方式")
    private Integer jsType;

    private BigDecimal price;

    private BigDecimal zAmount;

    @TableField(exist = false)
    private JcSysOrganization toOrganization;//目的网点
    @TableField(exist = false)
    private List<JcAbnormal> abnormals;//异常对象
    @TableField(exist = false)
    private JcOrderBack orderBack;//订单回单
    @TableField(exist = false)
    private JcCustomer customer; //客户
    @TableField(exist = false)
    private JcSysOrganization fromOrganization; //组织机构(出发网点)
    @TableField(exist = false)
    private List<JcOrderReceivingParty> orderReceivingParties; //所属收发货方

    @TableField(exist = false)
    private JcOrderReceivingParty sender; //所属收发货方
    @TableField(exist = false)
    private JcOrderReceivingParty receiver; //所属收发货方

    @TableField(exist = false)
    private List<JcOrderProduct> orderProducts;//货品
    @TableField(exist = false)
    private List<JcLed> leds;//分段订单
    @TableField(exist = false)
    private List<JcOrderTrack> orderTracks;//追踪表
    @TableField(exist = false)
    private List<JcLedgerDetail> ledgerDetails;//台账明细
    @TableField(exist = false)
    private JcDispatch dispatch;//提派单
    @TableField(exist = false)
    private JcZoneStoreroom zoneStoreroom; //库存区域
    @TableField(exist = false)
    private JcServerZone startZone;    //出发运点
    @TableField(exist = false)
    private JcServerZone endZone;      //目的运点
    @TableField(exist = false)
    private JcPresco presco; //预录单ID
    @TableField(exist = false)
    private List<JcVerificationZb> verifications;//核销表

    // 核查状态
    private YesOrNo recheckStatus;
    private Date recheckTime;
    // 核查人
    @Dict(dictTable = "sys_user", dictLabel = "nick_name", dictValue = "user_id", dictAlias = "recheckUserName")
    private Long recheckUserId;
    // 核查名称
    @TableField(exist = false)
    private String recheckUserName;

}
